var vm =  new Vue({
      el : "#app",
      data : {
        reserveNo:'',//订单号
        reserveId:'',//订单id
        name:'',//入住人
        ctrlTime:'',//控制时间
        openId:'',//登录成功后传的微信openId
        hotelName: '',  //入驻分店
        roomTypeName: '',//预定的房型
        peopleNname: '',//入住人姓名
        peopleTel: '',//入住人手机号
        inTime: null,      //入住时间
        outTime: null,     //离店时间
        roomsNum: 2,       //房间数
        payPrice: null,  //预定总价
        token:'',//固定token
        hotelId:'',//分店id
        time_end:''//30分倒计时时间戳s
 
      },
created:function(){ 
  //var pp= this.fmtDate(1506528000000)
  //alert(pp);
    this.token = _lSGet('token');
    this.openId = _lSGet('openId');
    this.reserveId = _lSGet('reserveId');//获取订单号id
    this.hotel = _lSGet('hotelId');//酒店id或分店id//这里是上上上个页面传的非上个
    this.timer=setInterval(this.GetRTime,0);
    //载入时加载信息
    var that=this;
    var params = {};
    params.id = that.reserveId;//订单号
    //params.hotelId = that.hotel;//酒店id
    params.token = that.token;
    sendRequest('/weChartOrder/get', params, function(res) {
    console.log('opop')
    console.log(res);
    that.go_login_home(res);
    //that.go_login_home(res)
    if(res.status==1){
       that.inTime= that.fmtDate(res.data.inTime);
       that.outTime= that.fmtDate(res.data.outTime);
       that.hotelName= res.data.hotelName;//入住分店
       that.roomsNum= res.data.roomCount;//房间数
       that.peopleTel= res.data.mobile;//手机号
       that.name= res.data.reserveName;//入住人
       that.reserveNo=res.data.reserveNo;
       that.roomTypeName= res.data.reserveModel.roomTypeName;//房间类型名
       that.payPrice= res.data.unpaidMoney;//订单总额
       that.time_end=res.data.leftTime;//结束时间
          }
        });       
    },

  mounted:function(){


  },
  methods:{
    fmtDate:function (obj){
        var date =  new Date(obj);
        var y = 1900+date.getYear();
        var m = "0"+(date.getMonth()+1);
        var d = "0"+date.getDate();
        return y+"-"+m.substring(m.length-2,m.length)+"-"+d.substring(d.length-2,d.length);
    },
    strToJson:function(str) {
        var json = eval('(' + str + ')');
        //console.info(json);
        return json;
        },
    GetRTime:function(){
         //var EndTime= new Date(Date.parse(re.endTime.replace(/-/g,"/")));//"2017-08-29 15:33:24
        var EndTime= new Date('2017/09/28 16:59:00');
        var NowTime = new Date();
        //var t =EndTime.getTime() - NowTime.getTime();
        var t =this.time_end - NowTime.getTime();
        this.ctrlTime=t;

        //console.log("ooo")
        //console.log(this.ctrlTime)
        var d=0;
        var h=0;
        var m=0;
        var s=0;
        if(t>=0){
        d=Math.floor(t/1000/60/60/24);
        h=Math.floor(t/1000/60/60%24);
        m=Math.floor(t/1000/60%60);
        s=Math.floor(t/1000%60);
        }
        $('#t_h').html(h + "时");
        //document.getElementById("t_m").innerHTML = m + "分";
        $('#t_m').html(m + "分");
        //document.getElementById("t_s").innerHTML = s + "秒";
        $('#t_s').html(s + "秒");
      },
    go_login_home:function(res){
      if(res.returnCode=="MEM-1001"){
           window.location.href=backUrl;
        }
    },
    sendRequest:function(urls,params,successFunc){
        $.ajax({
            type: "post",
            url:url+urls,
            data:params,
            cache:false,
            async:true,
            //dataType: 'json',
            success: successFunc
        });

    },
    go_order_current:function(){
        if(this.ctrlTime<=0){
            tips('订单已过期');
            return;
        }

        var that=this;
        var params = {};
        //params.hotelId = that.hotel;//分店id
        params.orderNo  = that.reserveNo;//订单号
        params.token = that.token;
        params.openId = that.openId;
        sendRequest('/wxPay/getPayPackage', params, function(res) {

            that.go_login_home(res);
            //that.go_login_home(res)
            if(res.status == 1) {
            var packageInfo = that.strToJson(res.data);
            window.WeixinJSBridge.invoke('getBrandWCPayRequest', packageInfo,
            function(re) {
                //alert(re);
                //支付成功或失败前台判断
                if (re.err_msg == 'get_brand_wcpay_request:ok') {
                window.location.href=indexUrl+'/app/history-order.html?_t=' + Math.random();//支付成功跳转到历史订单页面
                } else {
                layer.open({
                    content: '支付失败'
                    ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
                });
                }
            });
            }
        });
    }      
   },
  computed: {
  
     
  
  },
  watch:{
    
  },
  components:{
        
  }
 
      
});